package com.he.architecture.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.he.architecture.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Set;

@Entity
@Getter
@Setter
@Where(clause = "is_deleted = 0")
//商家新建的商品
public class ShopItem extends LogicEntity {
    @Column
    private String itemName;
    @Column(columnDefinition = "Double default 99999.0")
    private Double sugPrice;

    //商家和商品的一对多
    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = {"shops"})
    private Business business;

    //商品和上架商品的一对多关系
    @OneToMany(mappedBy = "shopItem",
            fetch = FetchType.LAZY,
            orphanRemoval = true,
            cascade = CascadeType.ALL)
    @JsonIgnoreProperties(value = {"shopItem"})
    private Set<Item> items;
}
